package com.ming.controller;

import com.ming.pojo.SSMAccount;
import com.ming.service.SSMAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


//表现层
@Controller
@RequestMapping("/ssmAccount")
public class SSMAccountController {

    @Autowired
    private SSMAccountService ssmAccountService;

    @RequestMapping("/findSSMAccountAll")
    public String findSSMAccount(Model model){
        System.out.println("执行了查询账户");
        //调用service方法
        List<SSMAccount> list = ssmAccountService.findSSMAccountAll();
        //暂时保存查询的数据
        for(SSMAccount list1:list){
            System.out.println(list1);
        }

        model.addAttribute("list",list);

        return "success";
    }

    @RequestMapping("/saveSSMAccountAll")
    public String saveSSMAccount(SSMAccount ssmAccount){
        System.out.println("执行了查询账户");
        ssmAccountService.saveSSMAccount(ssmAccount);
        return "redirect:findSSMAccountAll";
    }
}
